<template>
    <div class="main-container">
      <el-row style="">
        <!-- <el-col :span="24">
          <el-button size="mini" @click="copyAuthority">复用已有权限</el-button>
        </el-col> -->
      </el-row>
      <el-row :gutter="20">
        <el-col :span="24">
          <div class="tree-box">
            <div class="title">
              <span>{{$t('orgRoleManagement.setAuthorizeModal.sysFunction')}}</span>
            </div>
            <div class="tree">
                <el-checkbox-group v-model="moduleIds">
                    <el-checkbox 
                        v-for="(moduleItem,moduleIndex) in moduleList" 
                        :label="moduleItem.F_Id"
                        :key="moduleItem.F_Id">
                        {{moduleItem.F_Name}}
                    </el-checkbox>
                </el-checkbox-group>
            </div>
          </div>
        </el-col>
        <!-- <el-col :span="6">
          <div class="tree-box">
            <div class="title">
              <span>按钮权限</span>
            </div>
            <div class="tree">
                <p class="text-center">暂无权限</p>
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="tree-box">
            <div class="title">
              <span>字段权限</span>
            </div>
            <div class="tree">
                <p class="text-center">暂无权限</p>
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="tree-box">
            <div class="title">
              <span>表单权限</span>
            </div>
            <div class="tree">
                <p class="text-center">暂无权限</p>
            </div>
          </div>
        </el-col> -->
      </el-row>
    </div>
  </template>
  
  <script>
  import { getModulesByApp,getMyModulesByApp } from "@/api/organization/index";
  import { deepClone } from "@/utils/index";
  export default {
    name: "AppAuthorizeSelect",
    props: {
      objectType: {
        type: Number,
      },
      objectId: {
        type: String,
      }
    },
    data() {
      return {
        buttonList: [],
        columnList: [],
        formList: [],
        moduleList: [],
        moduleIds: [],
        buttonIds: [],
        columnIds: [],
        formIds: []
      };
    },
    mounted() {
       this.getModulesAll();
       this.getMyModules();

    },
    methods: {
      async getModulesAll() {
        const { data  } = await getModulesByApp()
        this.moduleList = data.data
      },
      async getMyModules() {
        
       const { data  } = await getMyModulesByApp(this.objectId,this.objectType)

        this.moduleIds = data.data[0]
      },
      allCheckChange() {
        let obj = {
          appModuleJson: this.moduleIds,
          appButtonJson: this.buttonIds,
          appColumnJson: this.columnIds,
          appFormJson: this.formIds
        };
        return obj;
      },
    }
  };
  </script>
  
<style lang="scss" scoped>
  .main-container {
    height: 100%;
    padding: 0 10px;
  }
  
  .tree-box {
    height: 666px;
    border-top: 1px solid #e9e9e9;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    box-sizing: border-box;
  }
  
  .tree-box .title {
    height: 40px;
    padding: 5px 20px;
    font-size: 14px;
    line-height: 30px;
    font-weight: bold;
    background: #fff;
    border: 1px solid #e9e9e9;
    border-top: none;
    border-bottom: none;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    box-sizing: border-box;
  }
  
  .tree-box .tree {
    height: calc(100% - 40px);
    padding: 20px;
    background: #fff;
    border: 1px solid #e9e9e9;
    overflow-y: auto;
    box-sizing: border-box;
  }

  .text-center{
      text-align: center;
  }
  @media screen and (max-width: 1370px) {
  	   .tree-box{
  		height: 420px;
  	   }   
  	} 
  </style>
  